<template>
  <div class="m20">
    <el-card shadow="always">
      <div class="df aic">
        <i class="el-icon-s-flag fs30"></i>
        <span class="titleText fs30">汇报</span>
      </div>
      <div class="mt10">企业对员工工作内容及过程的管理功能，可便捷的创建汇报内容、规则，为员工提供标准化的汇报渠道</div>
    </el-card>
    <div style="color:red" class="mt10 mb20">注：模板创建权限通过菜单管理配置</div>

    <el-card shadow="always">
      <div slot="header" class="clearfix">
        <span class="titleText">汇报管理</span>
        <el-button
          v-hasPermi="['reportManagement:reportPage:addBtn']"
          style="float: right; padding: 3px 0"
          @click="add"
          type="text"
        >创建汇报</el-button>
      </div>
      <el-tabs v-model="activeName" @tab-click="handleQuery">
        <el-tab-pane label="我管理的" name="1"></el-tab-pane>
        <el-tab-pane label="其他成员管理的" name="2"></el-tab-pane>
      </el-tabs>
      <el-table v-loading="loading" border :data="dataList">
        <el-table-column label="图标" align="center" prop="image">
          <template slot-scope="scope">
            <ImagePreview width="50px" height="50px" :src="scope.row.image"></ImagePreview>
          </template>
        </el-table-column>
        <el-table-column
          label="模板名称"
          align="center"
          prop="templateName"
          :show-overflow-tooltip="true"
        />

        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              v-if="activeName == 1"
              size="mini"
              type="text"
              v-hasPermi="['reportManagement:reportPage:del']"
              @click="handleDelete(scope.row)"
            >删除</el-button>
            <el-button
              v-if="activeName == 1"
              size="mini"
              type="text"
              v-hasPermi="['reportManagement:reportPage:edit']"
              @click="handleEdit(scope.row)"
            >编辑</el-button>
            <!-- <el-button size="mini" type="text" @click="handleDistribute(scope.row)">停用</el-button> -->
            <el-button size="mini" type="text" @click="handleDetails(scope.row)">汇报记录</el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />-->
    </el-card>
  </div>
</template>
<script>
import { reportTemplateList, reportTemplateDel } from "@/api/reportTm";
export default {
  components: {},
  props: [],
  data() {
    return {
      activeName: "1",
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 车型表格数据
      dataList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      // 查询车型
      queryParams: {
        // pageNum: 1,
        // pageSize: 10,
        carTypeName: undefined,
        carNumber: undefined,
        sendCode: undefined
      }
    };
  },
  computed: {},
  watch: {},
  created() {
    this.getList();
  },
  mounted() {},
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      this.queryParams.type = this.activeName;
      reportTemplateList(
        this.addDateRange(this.queryParams, this.dateRange)
      ).then(response => {
        this.dataList = response.data;
        this.total = response.total;
        this.loading = false;
      });
    },
    handleDelete(row) {
      this.$modal
        .confirm('是否确认删除"' + row.templateName + '"的汇报模板吗？')
        .then(function() {
          return reportTemplateDel(row.hotGoodsId);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    handleDetails() {
      this.$router.push("./reportRecord");
    },
    add() {
      this.$router.push("./addReport");
    },
    handleEdit(row) {
      this.$router.push("./addReport?id=" + row.reportTemplateId);
    },
    // 表单重置
    reset() {
      this.form = {
        sendOrderId: undefined,
        hopeTime: ""
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
};
</script>
<style scoped>
.titleText {
  font-weight: bold;
}
.fs30 {
  font-size: 30px;
}
</style>
